<?php

/* 
 *------------------------------------------------------------------------------
 * Project Name  : e-Synergy Library System
 *         Code  : ESN-LBS
 *
 * Created By    : Junlapong
 *         Date  : 2009/08/27 20:35
 * 
 * $Id$
 *------------------------------------------------------------------------------
 *    copyright: e-Synergy Co., Ltd.
 *==============================================================================
 */

if (!defined('BASEPATH')) exit('No direct script access allowed');

// TODO: change date() to gmdate() for adjust difference time ex. GMT+7 = diff 7 * 60 * 3600 sec.

/**
 * fm_date
 *
 * @access	public
 * @param	string
 * @param	string
 * @return	string
 */	
if (!function_exists('fm_date'))
{
	function fm_date($str_date, $str_format = "Y/m/d")
	{
		if (is_empty($str_date))
		{
			return "";
		}

		$time = strtotime($str_date);
		return date($str_format, $time);
	}	
}

// ------------------------------------------------------------------------

/**
 * fm_date_time
 *
 * @access	public
 * @param	string
 * @param	string
 * @return	string
 */	
if (!function_exists('fm_date_time'))
{
	function fm_date_time($str_date_time, $str_format = "Y/m/d H:i:s")
	{
		if (is_empty($str_date_time))
		{
			return "";
		}

		$time = strtotime($str_date_time);
		return date($str_format, $time);
	}
}

// ------------------------------------------------------------------------

/**
 * fm_number
 *
 * @access	public
 * @param	string
 * @param	string
 * @return	string
 */	
if (!function_exists('fm_number'))
{
	function fm_number($number, $decimals = 0, $dec_point = '.', $thousands_sep = ",")
	{
		if (is_empty($number))
		{
			return "";
		}

		return number_format($number, $decimals, $dec_point, $thousands_sep);
	}	
}

// ------------------------------------------------------------------------

/* End of file format_helper.php */
/* Location: application/helpers/format_helper.php */